#pragma once

#include <efi.h>

#define MR_PRESENT BIT(0)
#define MR_SKIP BIT(1)
#define MR_USABLE BIT(2)
#define MR_ACPI BIT(3)
#define MR_MEMHOLE BIT(4)

typedef struct {
	uint64_t number_of_pages;
	uint64_t number_of_free_pages;
	uint32_t attributes;
} mm_memory_region;

void mm_pallocator_init(efi_handle_t image_handle, efi_system_table *system_table);
uintptr_t mm_pallocator_alloc4k(uint64_t count);
void *mm_pallocator_valloc4k(uint64_t count, uint64_t map_flags);
int mm_pallocator_free4k(uintptr_t address, uint64_t count);
int mm_pallocator_vfree4k(void *p, uint64_t count);

mm_memory_region *mm_pallocator_get_memory_regions(uint64_t *output_count);

uint64_t mm_pallocator_get_total_pages();
uint64_t mm_pallocator_get_usable_pages();
uint64_t mm_pallocator_get_used_pages();
